<template>
  <div class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('申请单') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('申请标题') }}</td>
        <td colspan="3">{{ form.applyTitle }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('会议类型') }}</td>
        <td>
          {{ typeFormat(form.meetingType) }}
        </td>
        <td class="tit">{{ $t('会议时间') }}</td>
        <td>{{ parseTime(form.meetingTime) }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('我方参会人员') }}</td>
        <td>
          {{ form.ourParticipants }}
        </td>
        <td class="tit">{{ $t('其他参会人员') }}</td>
        <td>{{ form.otherParticipants }}</td>
      </tr>
    </table>
    <div v-if="form.bfPostMeetBillList && form.bfPostMeetBillList.length > 0" style="margin-bottom: 15px;">
      <div class="area-header">
        <span class="area-header-title">{{ $t('议案列表') }}</span>
      </div>
      <table class="previewTable">
        <thead>
          <th>{{ $t('议题内容') }}</th>
          <th>{{ $t('我方表决') }}</th>
          <th>{{ $t('说明') }}</th>
        </thead>
        <tbody>
          <tr v-for="(v, ind) in form.bfPostMeetBillList" :key="ind">
            <td>{{ v.topicContent }}</td>
            <td>{{ ourFormat(v.ourVote) }}</td>
            <td>{{ v.explainDetail }}</td>
          </tr>
        </tbody>
      </table>
    </div>
    <div v-if="form.bfProjectInfoList && form.bfProjectInfoList.length > 0" style="margin-bottom: 15px;">
      <div class="area-header">
        <span class="area-header-title">{{ $t('项目信息') }}</span>
      </div>
      <table class="previewTable" style="table-layout: fixed;">
        <thead>
          <th>{{ $t('公司名称') }}</th>
          <th>{{ $t('项目名称') }}</th>
          <th>{{ $t('关注等级') }}</th>
        </thead>
        <tbody>
          <tr v-for="(v, ind) in form.bfProjectInfoList" :key="ind">
            <td>{{ v.companyName }}</td>
            <td>{{ v.projectName }}</td>
            <td>{{ levelFormat(v.attentionLevel) }}</td>
          </tr>
        </tbody>
      </table>
    </div>
    <!-- 附件列表 -->
    <FileView :list.sync="form.fileList" data-type="post_invest_meet" :business-id="autoBusinessId($route.query.id, form)" />

  </div>
</template>

<script>
import { getBfPostInvestMeet } from '@/api/bf/postInvestMeet/bfPostInvestMeet'
export default {
  components: {
  },
  data() {
    return {
      form: {
        bfPostMeetBillList: [],
        bfProjectInfoList: [],
        fileList: []
      },
      ourVoteOptions: [],
      meetingTypeOptions: [],
      attentionLevelOptions: []
    }
  },
  created() {
    // 会议类型
    this.getDicts('post_meeting_type').then(response => {
      this.meetingTypeOptions = response.data
    })
    // 我方表决类型
    this.getDicts('our_vote').then(response => {
      this.ourVoteOptions = response.data
    })
    // 关注等级
    this.getDicts('attention_level').then(response => {
      this.attentionLevelOptions = response.data
    })
  },
  mounted() {
    this.$bus.$emit('async_done')
  },
  methods: {
    // 初始化数据
    init(data) {
      if (data != null && data.id !== undefined && data.id !== '' && data.id !== null) {
        getBfPostInvestMeet(data.id).then(response => {
            this.form = response.data
        })
      }
    },
    typeFormat(row) {
      return this.selectDictLabel(this.meetingTypeOptions, row)
    },
    ourFormat(row) {
      return this.selectDictLabel(this.ourVoteOptions, row)
    },
    levelFormat(row) {
      return this.selectDictLabel(this.attentionLevelOptions, row)
    }

  }

}
</script>
